<html><head><title>Specify a simple random effect in a GAMLSS Formula</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link rel="stylesheet" type="text/css" href="Rchm.css">
</head>
<body>

<table width="100%"><tr><td>random(gamlss)</td><td align="right">R Documentation</td></tr></table><object type="application/x-oleobject" classid="clsid:1e2a7bd0-dab9-11d0-b93a-00c04fc99f9e">
<param name="keyword" value="R:   random">
<param name="keyword" value=" Specify a simple random effect in a GAMLSS Formula">
</object>


<h2>Specify a simple random effect in a GAMLSS Formula</h2>


<h3>Description</h3>

<p>
Includes random effect terms in an GAMLSS model.
</p>


<h3>Usage</h3>

<pre>random(xvar, df = NULL, lambda = 0)</pre>


<h3>Arguments</h3>

<table summary="R argblock">
<tr valign="top"><td><code>xvar</code></td>
<td>
a factor </td></tr>
<tr valign="top"><td><code>df</code></td>
<td>
the target degrees of freedom</td></tr>
<tr valign="top"><td><code>lambda</code></td>
<td>
the smoothing parameter lambda which can be viewed as a shrinkage parameter.</td></tr>
</table>

<h3>Details</h3>

<p>
This is an experimental smoother for use with factors in gamlss(). 
It allows the fitted values for a factor predictor to be shrunk towards the overall mean, 
where the amount of shrinking depends either on lambda, or on the equivalent degrees of freedom. 
Similar in spirit to smoothing splines, this fitting method can be justified on Bayesian grounds or by a random effects model.
</p>
<p>
Since factors are coded by model.matrix() into a set of contrasts, care has been taken to add an appropriate "contrast" 
attribute to the output of random(). This zero contrast results in a column of zeros in the model matrix, 
which is aliased with any column and is hence ignored
</p>


<h3>Value</h3>

<p>
x is returned with class "smooth", with an attribute named "call" which is to be evaluated in the backfitting  <code>additive.fit()</code> 
called by <code>gamlss()</code></p>

<h3>Author(s)</h3>

<p>
Trevor Hastie (amended by Mikis Stasinopoulos)
</p>


<h3>References</h3>

<p>
Chambers, J. M. and Hastie, T. J. (1991). <EM>Statistical Models in S</EM>, Chapman and Hall, London. 
</p>
<p>
Rigby, R. A. and  Stasinopoulos D. M. (2005). Generalized additive models for location, scale and shape,(with discussion), 
<EM>Appl. Statist.</EM>, <B>54</B>, part 3, pp 507-554.
</p>
<p>
Stasinopoulos D. M., Rigby R.A. and Akantziliotou C. (2006) Instructions on how to use the GAMLSS package in R.
Accompanying documentation in the current GAMLSS  help files, (see also  <a href="http://www.gamlss.com/">http://www.gamlss.com/</a>).
</p>
<p>
Stasinopoulos D. M. Rigby R.A. (2007) Generalized additive models for location scale and shape (GAMLSS) in R.
<EM>Journal of Statistical Software</EM>, Vol. <B>23</B>, Issue 7, Dec 2007, <a href="http://www.jstatsoft.org/v23/i07">http://www.jstatsoft.org/v23/i07</a>.
</p>


<h3>See Also</h3>

<p>
<code><a href="gamlss.html">gamlss</a></code>, <code><a href="gamlss.random.html">gamlss.random</a></code>
</p>


<h3>Examples</h3>

<pre>
data(aids)
attach(aids)
# fitting a loess curve with span=0.4 plus the a quarterly  effect 
aids1&lt;-gamlss(y~lo(x,span=0.4)+qrt,data=aids,family=PO) # 
# now we string the quarterly  effect using random 
aids2&lt;-gamlss(y~lo(x,span=0.4)+random(qrt,df=2),data=aids,family=PO) # 
plot(x,y)
lines(x,fitted(aids1),col="red")
lines(x,fitted(aids2),col="purple")
rm(aids1,aids2)
detach(aids)
</pre>



<hr><div align="center">[Package <em>gamlss</em> version 1.7-9 <a href="00Index.html">Index]</a></div>

</body></html>
